<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ include file="../../base.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>数据 - AdminLTE2定制版</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
</head>
<script>
    function deleteById() {
        let id = getCheckId();
        if(id) {
            let state = document.getElementById(id).innerText;
            if (state == '草稿') {
                if(confirm("你确认要删除此条记录吗？")) {
                    location.href="/cargo/packing/delete?packingListId="+id;
                }
            } else {
                alert("无法删除已委托的装箱单");
            }
        }else{
            alert("请勾选待处理的记录，且每次只能勾选一个")
        }
    }

    function toView() {
        let id = getCheckId();
        if(id) {
            location.href="/cargo/packing/toView?packingListId="+id;
        }else{
            alert("请勾选待处理的记录，且每次只能勾选一个")
        }
    }

    function createShipping() {
        let id = getCheckId();
        if(id) {
            location.href = "${ctx}/cargo/packing/createShipping?packingListId="+id;
        }else{
            alert("请勾选待处理的记录，且每次只能勾选一个");
        }
    }
</script>
<body>
<div id="frameContent" class="content-wrapper" style="margin-left:0px;">
    <section class="content-header">
        <h1>
            货运管理
            <small>装箱管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="all-admin-index.html"><i class="fa fa-dashboard"></i> 首页</a></li>
        </ol>
    </section>
    <!-- 内容头部 /-->

    <!-- 正文区域 -->
    <section class="content">

        <!-- .box-body -->
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">装箱管理列表</h3>
            </div>

            <div class="box-body">

                <!-- 数据表格 -->
                <div class="table-box">

                    <!--工具栏-->
                    <div class="pull-left">
                        <div class="form-group form-inline">
                            <div class="btn-group">
                                <button type="button" class="btn btn-default" title="查看" onclick='toView()'><i class="fa fa-file-o"></i> 查看</button>
                                <button type="button" class="btn btn-default" title="删除" onclick='deleteById()'><i class="fa fa-trash-o"></i> 删除</button>
                                <button type="button" class="btn btn-default" title="生成委托书" onclick='createShipping()' id="createShipping"><i class="fa fa-file-o"></i> 生成委托书</button>
                            </div>
                        </div>
                    </div>
                    <div class="box-tools pull-right">
                        <div class="has-feedback">
                            <input type="text" clas
                                   s="form-control input-sm" placeholder="搜索">
                            <span class="glyphicon glyphicon-search form-control-feedback"></span>
                        </div>
                    </div>
                    <!--工具栏/-->

                    <!--数据列表-->
                    <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                        <thead>
                        <tr>
                            <th class="" style="padding-right:0px;">
                                <input type="checkbox" name="selid" onclick="checkAll('id',this)">
                            </th>
                            <th class="sorting">报运合同号</th>
                            <th class="sorting">装箱时间</th>
                            <th class="sorting">总体积</th>
                            <th class="sorting">总净重</th>
                            <th class="sorting">总毛重</th>
                            <th class="sorting">唛头</th>
                            <th class="sorting">描述</th>
                            <th class="sorting">装箱费用</th>
                            <th class="sorting">装箱时间</th>
                            <th class="sorting">状态</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${pageInfo.list}" var="packing">
                            <tr>
                                <td><input type="checkbox" name="packingListId" value="${packing.packingListId}"/></td>
                                <td>${packing.exportNos}</td>
                                <td><fmt:formatDate value="${packing.packingTime}" pattern="yyyy-MM"/></td>
                                <td>${packing.totalVolume}</td>
                                <td>${packing.netWeights}</td>
                                <td>${packing.grossWeights}</td>
                                <td>${packing.marks}</td>
                                <td>${packing.descriptions}</td>
                                <td>${packing.packingMoney}</td>
                                <td><fmt:formatDate value="${packing.packingTime}" pattern="yyyy-MM"/></td>
                                <td id="${packing.packingListId}">${packing.state == 0 ? '草稿' : '<font color="red">已委托</font>'}</td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="box-footer">
                <jsp:include page="../../common/page.jsp">
                    <jsp:param value="${ctx}/cargo/packing/list" name="pageUrl"/>
                </jsp:include>
            </div>
        </div>
    </section>
</div>
</body>
</html>